//背景轮播图
var n = 1;
var bg = document.querySelector('.bg');
console.log(bg);

function changespic() {
    bg.style.backgroundImage = 'url(images/pic' + n + '.jpg)';
    n++;
}
function proload(){
    if (n > 7) {
        n = n - 7;
    }
    var img = document.querySelector('img');
    img.src='images/pic' + n + '.jpg';
    setTimeout(changespic, 1000);
    console.log(n);
}
var a = setInterval(proload, 7000);

//侧边栏渐变动画
var nav = document.querySelector('.nav');
console.log(nav);
nav.onmouseover = function () {
    nav.style.backgroundColor = 'rgba(0, 0, 0, 0.3)';
    nav.style.animation = 'move1 .5s linear forwards';
}
nav.onmouseout = function () {
    nav.style.backgroundColor = '';
    nav.style.animation = 'move2 .5s linear forwards';
}

//日期函数
function dateday() {
    var date = new Date();
    var week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
    var day = week[date.getDay()];
    return (date.getMonth() + 1) + '月 ' + date.getDate() + '日 ' + day;
}
console.log(dateday());

// 时间函数
function GetTime() {
    var time = new Date();
    var h = time.getHours();
    if (0 <= h && h < 4) {
        return '凌晨了';
    } else if (4 <= h && h < 9) {
        return '早上好';
    } else if (9 <= h && h < 12) {
        return '上午好';
    } else if (12 <= h && h < 13) {
        return '中午好';
    } else if (13 <= h && h < 18) {
        return '下午好';
    } else {
        return '晚上好';
    }
}
console.log(GetTime());
function printword() {
    var word = document.querySelector('.word');
    word.innerHTML = '<span>' + GetTime() + '，打工人</span><br>今天是 ' + dateday();
}
printword();
var a = setInterval(printword, 600000);

let login_button=document.querySelector("#login_button");
let logbox=document.querySelector(".logbox");
login_button.addEventListener("click",()=>{
    console.log(1);
    if(logbox.style.display=="none"){
        logbox.style.display="block"
    }else{
        logbox.style.display="none"
    }
})